import SDKManager from "../../sdk/SDKManager";
import { ResultState, SDKState } from "../../sdk/SDKConfig";
import BagManager from "./BagManager";
import { InitValue } from "../../public/Config";


export default class RecorderManager {



    static  start() {
        let recorder = SDKManager.getChannel().getRecorder()
        if (recorder.getVideoPath()) {
            SDKManager.getChannel().showShare(0, (result: ResultState) => {
                // SDKManager.getChannel().showToast('录频分享结果：' + result)
                console.log(' 录屏分享结果  has path  ', result)
                recorder.clear()
                if (result == ResultState.YES) {
                    BagManager.addCoin(InitValue.shareNum)
                } else {
                  
                }
                // this.setState(RecorderState.IDLE)
            }, true)
        } else {

            if (recorder.getState() == SDKState.close) {
                SDKManager.getChannel().recorderStart()
            } else {
                SDKManager.getChannel().recorderStop(true, (state: ResultState) => {
                    if (state == ResultState.YES) {
                        SDKManager.getChannel().showShare(0, (result: ResultState) => {
                            // SDKManager.getChannel().showToast('录频分享结果：' + result)
                            console.log(' 录屏分享结果    ', result)
                            recorder.clear()
                            if (result == ResultState.YES) {
                                BagManager.addCoin(InitValue.shareNum)
                            }
                            // this.setState(RecorderState.IDLE)
                        }, true)
                    } else {

                    }

                })
            }


        }
    }
}